﻿package mortal.common.swfPlayer.data
{
    import mortal.common.swfPlayer.frames.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.player.info.*;

    public class MovieClipData extends Object implements IMovieClipData
    {
        protected var _frames:SwfFrames;
        protected var _url:String;
        protected var framestype:String;
        protected var _modelInfo:IModelInfo;
        private var _referenceCount:int = 0;
        private var _loadPriority:int = 2;
        static const MAX_FRAME:int = 15;

        public function MovieClipData(param1:String)
        {
            this.framestype = param1;
            return;
        }// end function

        public function get pointY() : Number
        {
            if (this._frames)
            {
                return this._frames.pointY;
            }
            return 0;
        }// end function

        public function get modleType() : int
        {
            if (this._frames)
            {
                return this._frames.modleType;
            }
            return 0;
        }// end function

        public function get isSouthTop() : Boolean
        {
            if (this._frames)
            {
                return this._frames.isSouthTop;
            }
            return false;
        }// end function

        public function get isNorthTop() : Boolean
        {
            if (this._frames)
            {
                return this._frames.isNorthTop;
            }
            return false;
        }// end function

        public function get fireFrame() : int
        {
            if (this._frames)
            {
                return this._frames.fireFrame;
            }
            return 0;
        }// end function

        public function set modelInfo(param1:IModelInfo) : void
        {
            this._modelInfo = param1;
            return;
        }// end function

        public function get url() : String
        {
            return this._url;
        }// end function

        public function removeReference() : void
        {
            var _loc_1:String = this;
            var _loc_2:* = this._referenceCount - 1;
            _loc_1._referenceCount = _loc_2;
            if (this._frames)
            {
                this._frames.removeReference();
            }
            return;
        }// end function

        public function addReference() : void
        {
            if (this._referenceCount < 0)
            {
                this._referenceCount = 0;
            }
            var _loc_1:String = this;
            var _loc_2:* = this._referenceCount + 1;
            _loc_1._referenceCount = _loc_2;
            return;
        }// end function

        public function get referenceCount() : int
        {
            return this._referenceCount;
        }// end function

        protected function setFrames(param1:String = null) : void
        {
            if (this._frames == null)
            {
                this._frames = FrameTypeConfig.instance.getFramesByType(this.framestype).clone();
            }
            if (this._frames)
            {
                this._frames.movieClip = null;
            }
            return;
        }// end function

        public function getFrames(param1:int, param2:int) : FrameArray
        {
            return this._frames.getFrames(param1, param2);
        }// end function

        public function getActionInfo(param1:int) : ActionInfo
        {
            return this._frames.getActionInfo(param1) as ActionInfo;
        }// end function

        public function load(param1:String, param2:Function) : void
        {
            this._url = param1;
            this._frames = FramesData.getData(param1);
            if (this._frames == null)
            {
                if (this._modelInfo == null)
                {
                    this.setFrames(null);
                }
                else
                {
                    this.setFrames(this._modelInfo.modelId);
                }
                if (this._frames)
                {
                    FramesData.addData(param1, this._frames);
                }
            }
            if (this._frames)
            {
                this._frames.loadPriority = this._loadPriority;
                this._frames.load(param1, param2);
            }
            return;
        }// end function

        public function get actionConut() : int
        {
            if (this._frames)
            {
                return this._frames.actionConut;
            }
            return 0;
        }// end function

        public function getFrame(param1:Object) : int
        {
            if (param1 is Number)
            {
                return int(param1);
            }
            return -1;
        }// end function

        public function isClear(param1:Boolean) : void
        {
            if (this._frames)
            {
                this._frames.isClear = param1;
            }
            return;
        }// end function

        public function dispose() : void
        {
            if (this._frames.referenceCount <= 0)
            {
                this._frames.dispose();
            }
            this._referenceCount = -1;
            return;
        }// end function

        public function get loadPriority() : int
        {
            return this._loadPriority;
        }// end function

        public function set loadPriority(param1:int) : void
        {
            this._loadPriority = param1;
            return;
        }// end function

    }
}
